package com.ssy.lingxi.order.entity;

import com.fasterxml.jackson.annotation.JsonBackReference;

import javax.persistence.*;
import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDateTime;

/**
 * 采购流程规则配置关联的合同
 * @author 万宁
 * @version 2.0.0
 * @date 2021-07-24
 */
@Entity
@Table(schema = "public", name = "ord_purchase_process_contract", indexes = {@Index(name = "ord_purchase_process_contract_purchase_process_id_idx", columnList = "purchase_process_id"), @Index(name = "ord_purchase_process_contract_contract_id_idx", columnList = "contractId")})
public class OrderPurchaseProcessContractDO implements Serializable {
    private static final long serialVersionUID = 96450401877716726L;

    /**
     * 主键Id
     */
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "ord_purchase_process_contract_seq")
    @SequenceGenerator(sequenceName = "ord_purchase_process_contract_seq", name = "ord_purchase_process_contract_seq", allocationSize = 1)
    private Long id;

    /**
     * 多对一双向关联采购流程规则
     */
    @JsonBackReference
    @ManyToOne(cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
    @JoinColumn(name = "purchase_process_id")
    private OrderPurchaseProcessDO process;

    /**
     * 合同Id
     */
    @Column
    private Long contractId;

    /**
     * 合同编号
     */
    @Column(columnDefinition = "varchar(20)")
    private String contractNo;

    /**
     * 合同摘要
     */
    @Column(columnDefinition = "varchar(60)")
    private String digest;

    /**
     * 生效时间
     */
    @Column(columnDefinition = "timestamp")
    private LocalDateTime effectTime;

    /**
     * 失效时间
     */
    @Column(columnDefinition = "timestamp")
    private LocalDateTime expireTime;

    /**
     * 合同乙方
     */
    @Column(columnDefinition = "varchar(200)")
    private String partyB;

    /**
     * 合同金额
     */
    @Column(columnDefinition = "numeric")
    private BigDecimal amount;

    /**
     * 合同寻源类型，定义在 ContractSourceTypeEnum 中, 0-所有类型，1-采购询价，2-采购招标，3-采购竞价
     */
    @Column
    private Integer contractType;

    /**
     * 对应单据
     */
    @Column(columnDefinition = "varchar(30)")
    private String receiptNo;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public OrderPurchaseProcessDO getProcess() {
        return process;
    }

    public void setProcess(OrderPurchaseProcessDO process) {
        this.process = process;
    }

    public Long getContractId() {
        return contractId;
    }

    public void setContractId(Long contractId) {
        this.contractId = contractId;
    }

    public String getContractNo() {
        return contractNo;
    }

    public void setContractNo(String contractNo) {
        this.contractNo = contractNo;
    }

    public String getDigest() {
        return digest;
    }

    public void setDigest(String digest) {
        this.digest = digest;
    }

    public LocalDateTime getEffectTime() {
        return effectTime;
    }

    public void setEffectTime(LocalDateTime effectTime) {
        this.effectTime = effectTime;
    }

    public LocalDateTime getExpireTime() {
        return expireTime;
    }

    public void setExpireTime(LocalDateTime expireTime) {
        this.expireTime = expireTime;
    }

    public String getPartyB() {
        return partyB;
    }

    public void setPartyB(String partyB) {
        this.partyB = partyB;
    }

    public BigDecimal getAmount() {
        return amount;
    }

    public void setAmount(BigDecimal amount) {
        this.amount = amount;
    }

    public Integer getContractType() {
        return contractType;
    }

    public void setContractType(Integer contractType) {
        this.contractType = contractType;
    }

    public String getReceiptNo() {
        return receiptNo;
    }

    public void setReceiptNo(String receiptNo) {
        this.receiptNo = receiptNo;
    }
}
